<?php

declare (strict_types=1);

namespace App\Model;

use App\Utils\Upload\View;
use Hyperf\DbConnection\Model\Model;

/**
 * Class ConfigBanner
 * @package App\Model
 * @property mixed|int id
 * @property mixed|int cooperative_id
 */
class ConfigBanner extends Model
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'config_banner';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = ['type', 'ext', 'rank', 'image'];
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = [];

    public function getImageAttribute($value)
    {
        if ($value) {
            return di(View::class)->fullPath($value);
        } else {
            return '';
        }
    }

}